package com.cn.longdistancebusstation.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ListView;
import android.widget.TextView;

import com.cn.longdistancebusstation.R;
import com.cn.longdistancebusstation.model.Station;

import java.util.List;

/**
 * Created by mucheng on 2018/2/8.
 */

public class StationPointAdapter extends BaseAdapter{
    private Context ctx;
    private List<Station> mStationPoint;
    public StationPointAdapter(Context ctx,List<Station> mStationPoint){
        this.ctx=ctx;
        this.mStationPoint=mStationPoint;

    }
    @Override
    public int getCount() {
        return mStationPoint.size();
    }

    @Override
    public Object getItem(int i) {
        return mStationPoint.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        ViewHolder holder=null;
        if(view==null){
            holder=new ViewHolder();
            view= LayoutInflater.from(ctx).inflate(R.layout.view_pop_station_name,null);
            holder.tv_stationNumber=(TextView) view.findViewById(R.id.serial_numbers);
            holder.tv_stationPointName=(TextView)view.findViewById(R.id.station_names);
            view.setTag(holder);
        }else{
            holder=(ViewHolder)view.getTag();

        }
        Station mstation=mStationPoint.get(i);
        holder.tv_stationNumber.setText(mstation.getStationID());
        holder.tv_stationPointName.setText(mstation.getStationName());
        return view;
    }
    class ViewHolder{
        TextView tv_stationNumber;
        TextView tv_stationPointName;
    }
}
